<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
      <!-- 保存选中的水果 -->
      <!-- select的单选 -->
      <select v-model="fruit">
        <option value="apple">苹果</option>
        <option value="orange">橘子</option>
        <option value="banana">香蕉</option>
      </select>
      <h2>单选：{{fruit}}</h2>
      <hr>
      <!-- select的多选 -->
      <!-- 按住shift或者ctrl多选 -->
      <!-- 1.select的值绑定 -->
      <select multiple size="3" v-model="fruits">
        <option v-for="(item,index) in allFruits" :key="item.value" :value="item.value">
          {{item.text}}
        </option>
      </select>
      <h2>多选：{{fruits}}</h2>

      <!-- 2.checkbox的值绑定 -->
      <div class="hobbies">
        <h2>请选择你的爱好</h2>
        <template v-for="item in allHobbies" :key="item.value">
          <label :for="item.value" >
            <input :id="item.value" type="checkbox" :value="item.value" v-model="hobbies">{{item.text}}
          </label>
        </template>
        <h2>爱好：{{hobbies}}</h2>
      </div>

    </div>

    <script src="./lib/Vue.js"></script>
    <script>
        const app = Vue.createApp({
            data() {
                return{
                  // 水果
                  allFruits:[
                    { value: "apple", text: "苹果" },
                    { value: "orange", text: "橘子" },
                    { value: "banana", text: "香蕉" }
                  ],
                  // 爱好
                  allHobbies: [
                    {value:'sing',text:"唱"},
                    {value:'jump',text:"跳"},
                    {value:'rap',text:"rap"},
                    {value:'basketball',text:"篮球"}
                  ],
                  fruit: "apple",
                  fruits:[],
                  hobbies:[]
                }
            }
        })
        app.mount("#app")
    </script>
</body>
</html>